using System;
using System.ComponentModel;
using System.Data;
using System.Collections.Generic;

namespace PlacementManager
{
	public partial class NoteComponent
    {
		//
		// TODO: Add constructor logic here
		//

        /// <summary>
        /// Selects all records from the database table based on a foreign key.
        /// </summary>
        /// <returns>A collection of objects of a type representing a row in the database table.</returns>
        [DataObjectMethodAttribute(DataObjectMethodType.Select, true)]
        public List<Note> SelectAllWNoteTypeIdEntityId(int NoteTypeId, int EntityId, string sortExpression)
        {
            List<Note> listNote = new List<Note>();
            PlacementManager.DAL.Note_DAL o = new PlacementManager.DAL.Note_DAL();
            o.NoteTypeId = NoteTypeId;
            o.EntityId = EntityId;
            DataSet ds = o.SelectAllWNoteTypeIdEntityId();
            foreach (DataRow row in ds.Tables[0].Rows)
            {
                listNote.Add(new Note((int)row["NoteId"], (int)row["NoteTypeId"], (int)row["EntityId"], (string)row["NoteText"], (bool)row["IsActive"], (DateTime)row["DateCreated"], (string)row["CreatedBy"], (DateTime)row["DateUpdated"], (string)row["UpdatedBy"]));
            }
            if (sortExpression == string.Empty)
            {
                sortExpression = "DateCreated asc";
            }
            listNote.Sort(new NoteComparer(sortExpression));
            return listNote;
        }
	}
}
